const Koa = require('koa')
const { resolve } = require('path')
const glob = require('glob')
const config = require('./config')

const useMiddlewares = app => {
  glob.sync(resolve(__dirname, './middlewares', '**/*.js')).forEach(item => {
    require(item)(app)
  })
}

(async () => {

  const app = new Koa()
  const server = require('http').Server(app.callback())
  
  console.log('挂载中间件...')
  useMiddlewares(app)

  server.listen(config.server.PORT, () => {
    console.log('正在监听' + config.server.PORT + '端口...')
  })
  
})()





